package com.lbb.simple.demo.widget.tab.bottom

import android.view.LayoutInflater
import android.view.ViewGroup
import com.lbb.simple.R
import com.lbb.simple.databinding.ItemTabBottomBinding
import com.lbb.utils.ActivityCollectorUtil
import com.lbb.utils.ThemeUtil
import com.lbb.utils.recycler.BaseHolder
import com.lbb.utils.recycler.BaseModelAdapter
import com.lbb.utils.recycler.BaseViewHolder
import com.lbb.utils.recycler.RecyclerListener

class Adapter : BaseModelAdapter<TabItem, ItemTabBottomBinding>() {
    var onClickListener: RecyclerListener.OnClickListener<TabItem>? = null

    init {
        list = mutableListOf(
            TabItem(true, R.drawable.ic_baseline_home_24, "首页"),
            TabItem(false, R.drawable.ic_baseline_music_note_24, "FM")
        )
    }

    fun setPosition(position: Int) {
        for (item in list) {
            item.check = false
        }
        list[position].check = true
        notifyDataSetChanged()
    }

    override fun getBinDing(parent: ViewGroup): ItemTabBottomBinding {
        return ItemTabBottomBinding.inflate(LayoutInflater.from(context), parent, false)
    }

    override fun onBindHolder(holder: BaseViewHolder, position: Int) {

                if(holder is BaseHolder<*>){

                    holder.binding.textView
                }
//        holder.binding.textView.text = list[position].title
//        holder.binding.imageView.setImageResource(list[position].img)
//        val activity = ActivityCollectorUtil.getLastActivity()
//        activity?.let { activity_ ->
//            holder.binding.textView.setTextColor(
//                ThemeUtil.getColor(
//                    activity_,
//                    R.attr.textHintColor
//                )
//            )
//            holder.binding.imageView.setColorFilter(
//                ThemeUtil.getColor(
//                    activity_,
//                    R.attr.textHintColor
//                )
//            )
//            if (list[position].check) {
//                holder.binding.textView.setTextColor(
//                    ThemeUtil.getColor(
//                        activity_,
//                        R.attr.colorAccent
//                    )
//                )
//                holder.binding.imageView.setColorFilter(
//                    ThemeUtil.getColor(
//                        activity_,
//                        R.attr.colorAccent
//                    )
//                )
//            }
//        }
//
//        holder.itemView.setOnClickListener {
//            setPosition(position)
//            onClickListener?.onClick(
//                holder.itemView,
//                list[position],
//                position
//            )
//        }
    }

    override fun <BaseHolderItemTabBottomBinding> onBindHolder(holder: BaseHolder<ItemTabBottomBinding>, position: Int) {

    }
}